package com.nkzy.service.impl;

import com.nkzy.dao.UserDao;
import com.nkzy.domain.User;
import com.nkzy.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Create by 王建烨 on 2022/4/15 11:24
 **/

@Service  // 业务层
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;

    /**
     * 添加用户
     * @param user
     */
    @Override
    @Transactional // 事务
    public void addUser(User user) {
        userDao.insertUser(user);
    }

    /**
     * 查询所有用户
     * @return
     */
    @Override
    public List<User> queryAllUser() {
        return userDao.queryAllUser();
    }

    @Override
    public User query(Integer id) {
        return userDao.query(id);
    }

    @Override
    public void delete(Integer id) {
        userDao.delete(id);
    }

    @Override
    @Transactional
    public void update(User user) {
        userDao.update(user);
    }

    @Override
    public List<User> queryUserByPagination(Integer pageSize, Integer page) {
        return userDao.queryUserByPagination(pageSize,page);
    }

    @Override
    public int queryTotalPagination(Integer pageSize) {
        return userDao.queryTotalPagination(pageSize);
    }
}
